<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>each</title>
    <script src="./js/jquery-3.4.1.min.js"></script>
    <script>
        $(function () {
            let li=$("ul li");
            li.each(function (i,str) {
                $(str).html("这是第"+(i+1)+"个li，内容是"+(i+1));
                if(i>5)
                    return false;
            })
        $("ul").find("#d3").css({"background":"red","font-size":"30px"}).end().css("border"," #01db04 2px solid");

        });

    </script>
</head>
<body>
<ul>
    <li>1</li>
    <li>2</li>
    <li id="d3">3</li>
    <li>4</li>
    <li>5</li>
    <li>6</li>
    <li>7</li>
    <li>8</li>
    <li>9</li>
</ul>


</body>
</html>